/** 
  Copyright (c) 2008, 2009 Claudio Imbrenda
  This program is released under the terms of the
  GNU GPL version 3 or later.
*/

package macchina;
import javax.script.*;
import java.io.*;

public class prova{

public static void main(String a[])throws FileNotFoundException,IOException{
 Macchina m = new Macchina();
 System.out.println(Macchina.ABOUTSTRING);

 m.setTI((short)0x800);
 m.setExternal(false);
 m.setMode(Macchina.AUTOMATIC_MODE);
 m.setN((short)40);
 
 m.addRU(new myRU());
 
 m.loadMemDump(new File("b.dump"),0);
 m.loadMemDump(new File("helloworld.dump"),40);
 
 m.start();
 m.join();
 dump(m);
}


 public static void dump(Macchina m){
  System.out.println("Macchina Ridotta DUMP:\n"+
    "TI: "+m.getTI()+" TM: "+m.getTM()+" \n"+
    " A: "+m.getA()+ "  B: "+m.getB()+ "  N: "+m.getN()+"\n"+
    "MEMORIA:"
  );
  
  for(int rx=0;rx<128;rx++){
   System.out.print(""+8*rx+":\t");
   for(int cx=0;cx<8;cx++)
     System.out.print(""+m.getMEM((short)(8*rx+cx))+"\t");
   System.out.println("");
  }

 
 }

 private static class myRU implements RegistroUscita{
   public void write(byte b){
    System.err.print(MRUtils.toASCII(b));
   }
 }

}

